package com.cucheng.chatroom.web.controller;

import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cucheng.chatroom.model.po.UserInfo;
import com.cucheng.chatroom.model.vo.ResponseJson;
import com.cucheng.chatroom.service.UserInfoService;
import com.cucheng.chatroom.util.Constant;

@Controller
@RequestMapping("/chatroom")
public class ChatroomController {

    @Autowired
    UserInfoService userInfoService;

    /**
     *@Description: TODO(登录成功后，调用此接口进行页面跳转) 
     *@Author: wangchengjie
     *@Since: 2019年3月30日下午3:47:16
     *@return
     */
    @RequestMapping(method = RequestMethod.GET)
    public String toChatroom(){
        return "chatroom";
    }

    /**
     *@Description: TODO(获取登录用户的群组和好友信息) 
     *@Author: wangchengjie
     *@Since: 2019年3月29日下午4:28:09
     *@param session
     *@return
     */
    @RequestMapping(value = "/get_userinfo",method = RequestMethod.POST)
    @ResponseBody
    public ResponseJson getUserInfo(HttpSession session){
        UserInfo userInfo = (UserInfo) session.getAttribute (Constant.USER_TOKEN);
        userInfo = userInfoService.getUserInfoList (userInfo);
        return new ResponseJson ().success ().setData ("userInfo", userInfo);
    }
}
